/**
 * Extension of FactSearch class to perform specific Wiki Fact search
 * 
 **/

package com.syde322;

import java.util.ArrayList;

import android.util.Log;

public class WikiFactSearch extends FactSearch<WikiFacts> {

    public ArrayList<WikiFacts> find(String query) {
        ArrayList<WikiFacts> factsList = retrieveFactsList(query);
        return factsList;
    }

    public ArrayList<WikiFacts> find(String query, int maxResults) {
        ArrayList<WikiFacts> factsList = retrieveFactsList(query);
        return retrieveFirstResults(factsList, maxResults);
    }

    private ArrayList<WikiFacts> retrieveFactsList(String query) {
        String url = constructSearchUrl(query);
        String response = httpRetriever.retrieve(url);
        Log.d(getClass().getSimpleName(), "URL : " + url);
        Log.d(getClass().getSimpleName(), response);
        
        return xmlParser.parseFacts(response);
    }
    
}
